package br.com.fsa.aplication.Gui;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

import br.com.fsa.aplication.Exception.ConectionException;
import br.com.fsa.aplication.Model.LogisticaVO;
import br.com.fsa.aplication.Model.NotaFiscalVO;
import br.com.fsa.aplication.Services.LogisticaService;
import br.com.fsa.aplication.Services.NotaFiscalService;
import br.com.fsa.aplication.Util.NFDataModel;

@ManagedBean (name="nfMBean")
@RequestScoped
public class NotaFiscalMBean {

	private NotaFiscalService notaFiscalService = new NotaFiscalService();
	private List<NotaFiscalVO> notas = new ArrayList<NotaFiscalVO>();
	private NotaFiscalVO selectedNota = new NotaFiscalVO();
	private NotaFiscalVO nota = new NotaFiscalVO();

	private LogisticaService logisticaService = new LogisticaService();
	private List<LogisticaVO> logisticas = new ArrayList<LogisticaVO>();
	private LogisticaVO selectedLogistica = new LogisticaVO();
	private LogisticaVO log = new LogisticaVO();

	private long logistica;
	private NotaFiscalVO[] notasSelecionadas;
	private NFDataModel notasListadas;
	private NotaFiscalService servico = new NotaFiscalService();
	private HashMap dto = new HashMap();
	private HashMap parametros = new HashMap();
	private NotaFiscalVO nfSelecionada;
	
	public NotaFiscalMBean() {
		try {
			notas = notaFiscalService.listar();
			logisticas = logisticaService.listar();
		} catch (ConectionException e) {
			e.printStackTrace();
		}
	}
	
	public void atualizarNotasInicio() {
		parametros = new HashMap();
		parametros.put("logistica", logistica);
		dto.put("parametros", parametros);
		dto.put("tipo", "lista");
		notasListadas = new NFDataModel(servico.obterLista(dto));
	}

	public NotaFiscalVO getNota() {
		return nota;
	}

	public void setNota(NotaFiscalVO nota) {
		this.nota = nota;
	}

	public List<NotaFiscalVO> getNotas() {
		return notas;
	}

	public void setNotas(List<NotaFiscalVO> notas) {
		this.notas = notas;
	}

	public NotaFiscalVO getSelectedNota() {
		return selectedNota;
	}

	public void setSelectedNota(NotaFiscalVO selectedNota) {
		this.selectedNota = selectedNota;
	}
	
	public LogisticaService getLogisticaService() {
		return logisticaService;
	}

	public void setLogisticaService(LogisticaService logisticaService) {
		this.logisticaService = logisticaService;
	}

	public List<LogisticaVO> getLogisticas() {
		return logisticas;
	}

	public void setLogisticas(List<LogisticaVO> logisticas) {
		this.logisticas = logisticas;
	}

	public LogisticaVO getSelectedLogistica() {
		return selectedLogistica;
	}

	public void setSelectedLogistica(LogisticaVO selectedLogistica) {
		this.selectedLogistica = selectedLogistica;
	}
	
	
	public LogisticaVO getLog() {
		return log;
	}

	public void setLog(LogisticaVO log) {
		this.log = log;
	}
	public NFDataModel getNotasListadas() {
		return notasListadas;
	}

	public void setNotasListadas(NFDataModel notasListadas) {
		this.notasListadas = notasListadas;
	}
}
